package com.pekall.music.adapter;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.pekall.music.R;
import com.pekall.music.model.Music;

public class MusicListAdapter extends BaseAdapter {

    private Context mContext;
    private List<Music> mListMusic;

    public MusicListAdapter(Context con, List<Music> listMusic) {
        mContext = con;
        mListMusic = listMusic;
        Log.d("-----", mListMusic.toString());
    }

    
    public int getCount() {
        return mListMusic.size();
    }

    
    public Object getItem(int position) {
        return mListMusic.get(position);
    }

    
    public long getItemId(int position) {
        return position;
    }

    
    public View getView(int position, View convertView, ViewGroup parent) {
        
        if(convertView==null){
        convertView = LayoutInflater.from(mContext).inflate(R.layout.lineitem, null);
        }
        TextView lineItemDuration = (TextView) convertView.findViewById(R.id.LineItemDuration);
        ImageView lineItemImage = (ImageView) convertView.findViewById(R.id.LineItemImage);
        TextView lineItemName = (TextView) convertView.findViewById(R.id.LineItemName);
        TextView lineItemDescription = (TextView)convertView.findViewById(R.id.LineItemDescription);
        ImageView lineItemCheckImage = (ImageView) convertView.findViewById(R.id.LineItemCheckImage);
        lineItemDuration.setText(mListMusic.get(position).duration);
        lineItemDescription.setText(mListMusic.get(position).artist);
        lineItemName.setText(mListMusic.get(position).title);
        return convertView;
    }

}
